package setup

import (
	"github.com/shinedone/srv-framework/pkg/asserts"
	"github.com/shinedone/srv-framework/pkg/beans"
	"github.com/shinedone/srv-framework/pkg/https"
	"github.com/shinedone/srv-framework/pkg/services"
	"github.com/shinedone/srv-server/internal/client/data-adm/department"
	"github.com/shinedone/srv-server/internal/global/instance"
)

// 客户端注入
func ClientInit() {
	// 新建端点查找器
	ef := services.NewEndpointFinder(instance.GetViper())

	// 新建客户端
	departmentClient := department.NewClient(https.NewDefaultClient(), ef.GetGqlServerEndpoint("data-adm", "enterprise"))
	err := beans.ProvideBean(departmentClient)
	asserts.Nil(err, err)

	// 执行注入
	err = beans.Populate()
	asserts.Nil(err, err)
}
